<template>
	<view class="share">

		<!-- <image  mode="" :src="erweimaimg"></image> -->
		<view class="title">
			<image src="../../static/image/left.png" class="" @tap="back" style="margin-top: 100upx;"></image>
			<text>{{i18n.sharetitle}}</text>
		</view>
		<!--绘图-->
		<!-- <carousel :img-list="imgList" url-key="url" @selected="selectedBanner" style="margin-top: 180upx;" :erweimaimg="erweimaimg" /> -->
		<image :src="erweimaimg" mode=""  class="erweima" style="margin-top: 200upx;margin-left: 170upx;border:5upx solid RGBA(2, 201, 168, 1);border-radius: 25upx;"  @tap="erweimaTap"></image>
		<view class="yqm" :style="i18n.yqmbg">
			<image src="../../static/image/notice.png" class="bjimg"></image>
			{{yqm}}
		</view>
		<view class="fzyqm" @tap="fzyqm(yqm)">
			<image :src="i18n.yqimg1" mode="" :style="i18n.yqimg1style"></image>
		</view>
		<view class="kuang">
			<view class="kuangtext1">
				<view class="">
					{{i18n.yjkc}}：
				</view>
				<view class="">
					{{sumoex1}} OEX
				</view>
			</view>
			<view class="kuangtext1" style="border-bottom: 1px solid #0C5453;padding-bottom: 28upx;">
				<view class="">
					{{i18n.ejkc}}：
				</view>
				<view class="">
					{{sumoex2}} OEX
				</view>
			</view>
			<view class="kuangtext1" style="font-size:28upx">
				<view class="" style="font-size: 34upx;">
					{{i18n.kchj}}：
				</view>
				<view class="">
					<text style="color:#fff;font-size: 50upx;margin-right:10upx">{{zsl}} </text> <text style="font-size: 20upx:color:rgba(12, 84, 83, 1) ">OEX</text>
				</view>

			</view>

		</view>

		<view class="kuang2">
			<view class="smkuang">
				<view class="num">
					{{sl1}} <text class="dw">{{i18n.Miners}}</text>
				</view>
				<view class="smkuangtext" @tap="wenhaotap1(1)">
					<text>{{i18n.yjkc}} </text>
					<text> ｜ </text>
					<text>50% OEX</text>
					<image src="../../static/image/bwh.png" mode=""></image>
				</view>
				<image src="../../static/image/wenhao1.png" v-if="xs1" class="wenhao1"></image>
			</view>
			<view class="smkuang2">
				<view class="num">
					{{sl2}} <text class="dw">{{i18n.Miners}}</text>
				</view>
				<view class=" smkuangtext" @tap="wenhaotap1(2)">
					<text>{{i18n.ejkc}} </text>
					<text> ｜ </text>
					<text>25% OEX</text>
					<image src="../../static/image/bwh.png" mode=""></image>


				</view>
				<image src="../../static/image/wenhao2.png" v-if="xs2" class="wenhao2"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import carousel from '@/components/vear-carousel/vear-carousel'
	// import {
	// 	pathToBase64,
	// 	base64ToPath
	// } from '@/js_sdk/gsq-image-tools/image-tools/index.js'
	import account from '../../common/account.js'
	// import Mask from '@/components/mask/mask.vue';

	import _app from '@/util/QS-SharePoster/app.js';
	import {
		getSharePoster
	} from '@/util/QS-SharePoster/QS-SharePoster.js';
	export default {
		computed: {
			i18n() {
				return this.$t('user')
			}
		},
		components: {
			carousel
		},

		data() {
			return {
				xs1: false,
				xs2: false,
				avator: "",
				account: "",
				indicatorDots: false,
				autoplay: true,
				interval: 2000,
				duration: 1000,
				circular: true,
				yqm: "",
				accountName: "",
				sumoex1: "",
				sumoex2: "",
				sl1: "",
				sl2: "",
				zsl: "",
				img: [
					'../../static/image/share1.jpg',
					'../../static/image/share2.jpg',
					'../../static/image/share3.jpg'
				],
				imgList: [{
						url: '../../static/image/fxhb1.jpg',
						id: 1
					}, {
						url: '../../static/image/fxhb2.png',
						id: 1
					}, {
						url: '../../static/image/fxhb3.png',
						id: 1
					},
					{
						url: '../../static/image/fxhb4.png',
						id: 1
					},
					{
						url: '../../static/image/fxhb5.png',
						id: 1
					}
				],
				erweimaimg: "",
				coverUrl: "",
				baseimg: "",
				canvasimg: "",
				 
			}
		},
		onLoad(options) {
			console.log(options)
			this.yqm = options.yqmname
			this.accountName = options.accountName
			//交易信息
			const _this = this;
			uni.request({
				url: this.$API.appServeApi + this.$API.getwkjl + '?i18n_language=' + uni.getStorageSync('system_info'),
				data: {
					account: this.accountName
				},
				success(res) {
					if (res.data.code == 200 && res.data.data.length > 0) {
						//console.log(res.data.data)
						_this.sumoex1 = res.data.data[0].sumoex
						_this.sumoex2 = res.data.data[1].sumoex
						_this.sl1 = res.data.data[0].sl
						_this.sl2 = res.data.data[1].sl
						_this.zsl = Number(_this.sumoex1) + Number(_this.sumoex2)
						//console.log(_this.list)
					} else {
						//_this.$CommonJS.showToast(res.data.message)
					}
				},
				fail(e) {
					console.log(e)
					uni.hideLoading()
					_this.$CommonJS.showToast(e)
				}
			})
			if(uni.getStorageSync("erweimaimg")){
				_this.erweimaimg = uni.getStorageSync("erweimaimg") 
				var erweimaimga = this.$API.appServeApi + this.$API.getInvitationcodeimg + '?i18n_language=' + uni.getStorageSync('system_info') + "&account="+this.accountName
				uni.downloadFile({
				    url:this.$API.appServeApi + this.$API.getInvitationcodeimg + '?i18n_language=' + uni.getStorageSync('system_info') + "&account="+this.accountName , //仅为示例，并非真实的资源
				    success: (res) => {
				        if (res.statusCode === 200) {
				            console.log(res);
																_this.erweimaimg=res.tempFilePath
																uni.setStorageSync("erweimaimg",res.tempFilePath)
				        }
				    }
				});
			}else{
				var erweimaimga = this.$API.appServeApi + this.$API.getInvitationcodeimg + '?i18n_language=' + uni.getStorageSync('system_info') + "&account="+this.accountName
				_this.erweimaimg = erweimaimga
				uni.downloadFile({
				    url:this.$API.appServeApi + this.$API.getInvitationcodeimg + '?i18n_language=' + uni.getStorageSync('system_info') + "&account="+this.accountName, //仅为示例，并非真实的资源
				    success: (res) => {
				        if (res.statusCode === 200) {
				            console.log(res.tempFilePath);
																uni.setStorageSync("erweimaimg",res.tempFilePath)
				        }
				    }
				});
			}
		},
		 
		methods: {
			erweimaTap(){
				var _this=this;
				uni.downloadFile({
				    url: _this.erweimaimg, //仅为示例，并非真实的资源
				    success: (res) => {
				        if (res.statusCode === 200) {
				           uni.previewImage({
				           		urls: [res.tempFilePath],
				           		longPressActions: {
				           				itemList: [ '保存图片'],
				           				success: function(data) {
				           						if(data.tapIndex == 0){
				           							//保存到本地
				           							uni.saveImageToPhotosAlbum({
				           									filePath:res.tempFilePath,
				           									success: function () {
				           											_this.$CommonJS.showToast("图片保存成功");
				           									},
				           									fail(err) {
				           										_this.$CommonJS.showToast("图片保存失败");
				           									}
				           							});
				           						}
				           						
				           				},
				           				fail: function(err) {
				           						console.log(err.errMsg);
				           				}
				           		}
				           });
				        }
				    }
				});
			
			},
			fzyqm(e) {
				const _this = this;
				//提示模板
				uni.setClipboardData({
					data: e, //要被复制的内容
					success: () => { //复制成功的回调函数
						uni.showToast({ //提示
							title: _this._i18n.locale == 'zh_CN' ? '已复制' : 'Copied',
						})
					}
				});
			},
			back() {
				this.$CommonJS.navigateBack()
			},
			selectedBanner(item, index) {
				console.log(item, index)
			},
			mcshare() {
				this.mc = true
			},
			close() {
				this.mc = false
			},
			remove(val) {
				val == 1 ? this.mask = false : this.mask = true;
			},
			down() {

			},
			imgLista(e) {
				console.log(e.url)
			},
			changeIndicatorDots(e) {
				this.indicatorDots = !this.indicatorDots
			},
			changeAutoplay(e) {
				this.autoplay = !this.autoplay
			},
			intervalChange(e) {
				this.interval = e.target.value
			},
			durationChange(e) {
				this.duration = e.target.value
			},
			wenhaotap1(n) {

				if (n == 1) {
					this.xs2 = false;
					this.xs1 = !this.xs1;
				} else if (n == 2) {
					this.xs1 = false;
					this.xs2 = !this.xs2;
				}

			},
			saveImg() {
				uni.showLoading();
				const _this = this;
				this.img.map((item, index) => {
					uni.saveImageToPhotosAlbum({
						filePath: item,
						success: function() {
							if (index == 2) {
								uni.hideLoading();
								uni.showToast({
									title: _this._i18n.locale == 'zh_CN' ? '已保存' : 'Saved',
								})
							}

						}
					});
				})

			}
		}
	}
</script>

<style lang="stylus">
	@import "../../static/stylus/share/share.stylus"
</style>
